﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BusinessLogicLayer.DataObject
{
    public class ReserveRoom
    {
        public Room Room { get; set; }
        public DateTime From { get; set; }
        public DateTime To { get; set; }
        public string BackColor { get; set; }
        public string ForeColor { get; set; }
        public bool IsClean { get; set; }
        public List<Request> Requests { get; set; }

        public ReserveRoom(DataAccessLayer.Room Room, DateTime From, DateTime To, DataAccessLayer.linqDatabaseDataContext db)
        {
            this.Room = new Room( Room);
            this.From = From;
            this.To = To;
            this.IsClean = BusinessLogicLayer.DataObject.RoomClean.IsRoomClean(db, Room.RoomID);
            Requests = Request.Convert(DataAccessLayer.RequestRoom.ToListByRoomID_Filter(db, Room.RoomID, From, To).ConvertAll(new Converter<DataAccessLayer.RequestRoom, DataAccessLayer.Request>(p => p.sRequest.Requests.Last())));
        }

        public static List<ReserveRoom> Convert(List<DataAccessLayer.Room> Rooms, DateTime From, DateTime To, DataAccessLayer.linqDatabaseDataContext db)
        {
            return (Rooms.ConvertAll(new Converter<DataAccessLayer.Room, ReserveRoom>(p => (new ReserveRoom(p, From, To, db)))));
        }
    }
}
